package t1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class bat {
	public void runbat(String batnameString) {
		String cmd = "cmd /c D://" + batnameString + ".bat";
		Runtime runtime = Runtime.getRuntime();
		Process child = null;
		try {
			child = runtime.exec(cmd);
			InputStream in = child.getInputStream();
			String output = null;
			int isSuccessful = 0;
			BufferedReader bufferedReader = new BufferedReader(
					new InputStreamReader(in));

			output = bufferedReader.readLine();

			while (output != null) {

				System.out.println(output);

				output = bufferedReader.readLine();

			}

			try {
				// isSuccessful = child.waitFor();
			} catch (Exception e) {
				e.printStackTrace();
			}

		} catch (IOException ioe) {
			ioe.printStackTrace();
		} finally {
			child.destroy();
		}
		System.out.println("------------>ok");
	}

	public static void main(String[] args) {
		(new bat()).runbat("a");
	}
}
